package com.stnet.service.enterprice.dynamic;

import java.util.Date;
import java.util.List;

import com.modules.commons.Pager;
import com.stnet.bases.BaseManagerDaoImpl;
import com.stnet.entity.EnterpriseBulletin;

/**
 * @author Messcat
 * @version 1.1
 *
 */
public class EpBulletinManagerDaoImpl extends BaseManagerDaoImpl implements EpBulletinManagerDao{

    public EpBulletinManagerDaoImpl()
    {
    }

    public void addEnterpriseBulletin(EnterpriseBulletin enterpriseBulletin)
    {
        enterpriseBulletin.setEditeTime(new Date());
        //时间默认为当日起到10年后
        if(enterpriseBulletin.getInitTime() == null || "".equals(enterpriseBulletin.getInitTime().toString()))
        	enterpriseBulletin.setInitTime(new Date());
        if(enterpriseBulletin.getEndTime() == null || "".equals(enterpriseBulletin.getEndTime().toString()))
        {
            Date d = new Date();
            d.setDate(d.getDate() + 3650);
            enterpriseBulletin.setEndTime(d);
        }
        
        epBulletinDao.save(enterpriseBulletin);
    }

    public void deleteEpBulletin(Long id)
    {
        epBulletinDao.delete(id);
    }

    public Pager findEnterpriseBulletin(int pageSize, int pageNo, String statu)
    {
        Pager pager = epBulletinDao.getObjectListByClass(pageSize, pageNo,EnterpriseBulletin.class, statu);
        return pager;
    }

    public EnterpriseBulletin getEnterpriseBulletin(Long id)
    {
        return epBulletinDao.get(id);
    }

    public void updateEpBulletin(EnterpriseBulletin enterpriseBulletin)
    {
        enterpriseBulletin.setEditeTime(new Date());
        epBulletinDao.update(enterpriseBulletin);
    }

    public List findAllEnterpriseBulletin()
    {
        return epBulletinDao.findAllAct();
    }

    public List getEpInfoByClassAndSize(Long size, String isCommend)
    {
        return epBulletinDao.getInfoByClassAndSize("EnterpriseBulletin", size, Long.valueOf(-1L), "-1", isCommend, "-1", Long.valueOf(-1L), "-1");
    }
}